<?php
ini_set( 'include_path', '../;.' );

//
// In order to view the output you will need to download neato from http://www.graphviz.org/
//

require_once( 'include_package.php' );

include_package( 'Datasources' );
include_package( 'Datasources.Filters' );
include_package( 'DatabaseModel' );
include_package( 'Renderers' );
include_package( 'Renderers.HtmlRenderer' );
include_package( 'Renderers.DotRenderer' );
include_package( 'Renderers.DotRenderer.ImageGenerators' );

Session::Start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>P-dd: A simple example outputting the default DOT generated diagram using a filtered TestDatasource</title>
</head>
<body>
<p>Note that switching off 'ShowForeignKeysToFilteredTables' will result in filtered tables that reference, or are referenced by tables that are NOT filtered being hidden.  This means that not all foreign keys are shown, only those between un-filtered tables.</p>
<?php

$oDatasource = new TestDatasource();
$oFactory = new DatabaseFactory( new Filtration( $oDatasource, new Filter_TableReferencesTable( $oDatasource, 'SOCIETY_ACTIVITY' ) ) );
$oDatabase = $oFactory->ConstructDatabase();

$oConfiguration = new DotRendererConfiguration();
$oConfiguration->SetProperty( 'ShowForeignKeysToFilteredTables', false );

$oImageGenerator = new DotImageGenerator( DotDatabaseRenderer::Render( $oConfiguration, $oDatabase ) );
$sImage = $oImageGenerator->GenerateImageInSession( 'Gif', 'ExampleImage' );
echo( HtmlTag::Image( '../SessionImageLoader.php?ImageId='.$sImage, 'Dot generated diagram (using NEATO)') );

?>
</body>
</html>